More logging, cleaner server code