Preinitial draft from SERVER-AGENT architecture
Some minor bugs fixed