Fix some errors and lifecycle operations