Fixed various bugs. Now it works on Linux (Debian).