constructor and cleanup