bug fixes and switch