initial code refactor, no protobuf