Added comments. Eliminated extra spacing, printing debug functions and unused packages.