Big refactor + additional features