Merge "Fix code issues in APM found with unit tests"