Various optimizations and refactored relevant files in dist folder