Some code cleanup and standardization to SEI12 code standards. Also add Device ID handling.