implemented #846 and did some general cleanup and preperation for something else.