Major refactoring and clean up
merge commit, GPL and FocusChanger merged with refactoring