Moved some logic from frame to lightwriter