fixed: indentation, function locations, housekeeping