much much progress. sorry for this bad commit message.