better log handling, general cleanup