Added comments
Removed usage of globals
Added CLI