Cleaned constructors and destructors. Separated private functions.