Includes optimization. Closes #191.