Removing unused code and cleanup