Added a few functions and fixed some minor errors and problems

Added a few functions. Corrected some minor problems