How can I optimize this stored procedure
The answer to that is not exactly simple and hard to summarise in an allowable time frame.
The stored procedure doesn't exactly have any big performance issues, but you are generating dynamic SQL that may well have a non-optimal operation. This leads to plan-cache bloat and plans that cannot be re-used.
There are also some nested stored procedure calls that may be running slow, but this queryanalysis give no visibility to those.
Are you able to post the dynamic sql (and associated plans) that are being generated ? Use profiler with a Stored Procedure statement trace (not in a production environment though) to get those.