Removed some unused code and cleanup