Cleaned code

Removed legacy code
Added comments