Pruning and bugfixes, added custom $ lib