Several changes to compile with FPC on Linux