commenting properly, adding copyrights and some other shape-related fixes