Fixed a bug which caused function layers to run recursively (#152)