Refactoring

Refactored old code and merged Carbon code