cleanup code
bug fixes