Refractoring and Bug Fixes