Cleanup of the code. Removed obsolete code