bug fixes to Arduino code