All of the original code. Most comments and names are in Lithuanian, sorry about that