Bug Fixes and Tests