added support for hotstart and did some cleaning