Added machine learning capability, added signal handling, improved comments