slight code cleanup
Fixed a refresh bug, added refresh mode.