major bug fixes