removed js dependencies and shored up error handling significantly
added some code comments