Refactored code and tried to add more clarity.
Slightly stricter exception handling.
Added more javascript dependencies to remove random unstableness.
.