Little bug fixes and improvments