various bug fixes/exceptional cases