added prototypes for memory functions
touched up the code a bit