Removed unnecessary global variables. Cleaned up comments.