Merge with torleif/JSAMF + some major fixes