fix recursion bug in container_styles; refactor; fix padding calculation