Cleaned up some of code and added support for functions in when using the Error class.