Some style fixes, also fix off-by-one error in world/state