more cleanup, indentation, C style etc.