OPTIMIZATION: Minor optimizations in marksof and reduceCtx.

1. ".constructor" test is known to be faster than "instanceof".
2. Reduced the number of recursive calls in marksof using a while loop.