Multiple fixes and refinments to improve output