Code tidy and documentation. Also deob some silly names/consts.