Power level bug fixes

Bug fixes and minor changes related to distance calculation and power
level