Refactor a bit
Big refactor