python mode and general cleanup