Cleaned up the peripheral code