improve code, fix pep8 errors
create Cast class for custom casts