Added preprocess step and fixed a few issues