Removed debug and added comments
Tabs to spaces
Code refactor
Added comments to funcs