Remove duplicate code. Fix #78