corrected small I/O bugs from command line, added distance module, added command line run in examples