fixed some safety stuff, added checks for invalid location/name to few functions