bug and format fixes