Code improvements / small bug fixes