Cleaned up code

Fixed possible crash
Removed some debug messages