Fixed init and cleanup errors