Added error checking for unbound variables
Removed unused code