Proper handling of server commands. Some bug fixing.