beaglebone: code refactoring part 1