Initial working server - some flaws still exist