Small functions added; needs additional testing.