a mini cleanup --- code is still very convoluted, must clean up...