fix a segfault when closing with multiple tabs open
fix header dependencies
fixed switched mins and maxs, force min < max