Cleaned up code a bit to better follow ruby best practices