Code refactoring & dependency cleanup