Commented code and cleaned it up by removing dead code