Fix build failure and remove ~ files