some major bug fixes