convert to js
cleanup
pass on priority, and other info
fix leak
forgot comma
declare var