Cleaned up maxSize calculation and handle divide by 0 situation