Added real-time validity check

And other minor tweaks.