Fixed segfault and codelayout