Removed TODO comments
Added debug flag
Cleaned up some code