beaglebone: code refactoring