Cleaned up code

Cleaned up code based on @n1k0's suggestions.