Cleaned up code, proper initialization