Fixes for looping over arrays - bash is weird.
Fixed issue caused by using function to determine array membership
Still working on fixing assumed var names