refactors, bug fixes, additional test