Fixed some bugs in location plugin