Adds the auto layout support

Please review it and merge it.