Add step counter, and some optimisations for server.