Optimizations and some rebuilding procedures.