Tons of cleanups and small fixes