basic refactoring
cleanup and adding realtime capabilities