small logic fixes and additions