Add support for multiple configurations, and some misc fixes