Alot of refactoring work here..