norm fixes in lib files, foreach updates, r option working