Cleaned up code a bit and updated to follow standards