Fixed a bug with resolving limits in code generation