Rework of clientside code, cleaner but not compatible with server