organized some util, documented some code