cleaned up parser and refactored a bit. added pickling.