Hopefully fixed all glitches except three in a row

Changed the order of preference because of which everything seems to be
working. Please check and do the needful changes.