Refactor resource limits stuff