Removed dead code, added better comments