Several functions moved to where they are being used. Memory status now in its own file.