Replace System.out with logger + small bug fix