try document.onreadystatechange for init
cleanup and dependency correction