refactor to remove most of the static variables (fixes android UI pause/resume bug)