Few more optimizations and fixes upon minimizing