Safety and performance tweaks

* Replace unsafe `eval` calls with safe equivalents
* A few (uglyfying) tweaks to increase performance