simplifed a lot of logic, made lib.sh less dependant on dot
Lots of things