Fixed Dependency issues and code layout