Some fixes

Haven't fixed the crashing problem yet.