Cleaned up the code some