some improvments and cleanup