Cleaned up many variables, functions, and added enumeration support for counting