Cleaned up code

Based on advice from https://github.com/methane