put system implementation into peripheral.system; refactored common functionality.