moving some code in utils; removing dead code;
correct a bug;
clean code: preparing for lazyreferences;