More optimizations & clean-up of unused code