bug fixes/cleanup