Code cleanup, specs improvements