fix some frontend bugs and cleanup code