Removed some redundant code and general cleanup