Cleaning up flashlight code