Minor bug fixes on convert function