cleaned up the code a bunch, fixed naming inconsistencies