Fix flash and add CSS transitions