Fixed the stop function and compile errors