Initial commit of refactor. Still contains old code.