Cleaned up code, removed debug stuff