Removed obsolete code
Small optimizations