Fixed bug with calling functions inside an inline loop. Closes #1694