Reorganised implementation file, added memory warning processing.