cleanup js code, and add notification system