major refactor
merge with master