remove on_redirect_callback
change to id key and add manager to environment
move env_open and env_close into their own file, they are too big
make a handle_user_errors function
separate metadata work into another function
make more small functions