Fixed issues pointed out by Manishearth