bug fixes and refactors follow Brandons comments