make sizing work correctly, remove some duplicate code