fixed api shutdown sequence
server refactor, fixes
reverse proxy mode tested