Refactoring; bug in maxSpeed fixed