Updated to properly work with serial communcation