Merged in part of sals code by copying files