fixing some bugs causing crashes and poorly formatted messages

commits are self-explanatory