Cleaned up type conversion a bit