Some small code cleanups, commented out unused code, refactored code a little to not use functions in for loops, and added more strict type checking