Separated automatic and manual mode out, modularlized some stuff.