Set of fixes from debugging on a real server.