small bug fixes as per sonar report