Implements stage deployement and cleans up other stage code; adds tests