Merged well ported Wire library from prof. Mason