Refactor/overall fixes and QA