Cleaned up code. Added support for pow and sqrt.