completed major refactoring of device code into package structure