Fixed #526 fixed #536 fixed #535 and worked on #530 worked on #522