added thanks to @snipe for awesome bug fixes