code cleanup and better type adapter