Many little fixes to match demo program and my style