Fixed bug if BT stack inits incorrectly
Separated much of the logic into separate library project